<!--json转xml及xml转json-->

<template>
  <div>
    <!--数据栏-->
    <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
      <el-form :inline="true">
        <!--json框-->
        <el-form-item>
          <el-col>
            <el-input
              type="textarea"
              :rows="25"
              :cols="55"
              placeholder="json数据"
              v-model="textareainput"
            >
            </el-input>
            <el-button type="primary" @click="Json2Xml">Json2Xml</el-button>
          </el-col>
        </el-form-item>

        <!--输出框-->
        <el-form-item
          ><el-col>
            <el-input
              type="textarea"
              :rows="25"
              :cols="55"
              style="resize: none;"
              placeholder="xml数据"
              v-model="textareaoutput"
            >
            </el-input>
            <el-button type="primary" style="float:right" @click="Xml2Json"
              >Xml2Json</el-button
            ></el-col
          >
        </el-form-item>
      </el-form>
    </el-col>
    <!--Json2Xml-->
    <!--
    <el-button type="primary" @click="Json2Xml">Json2Xml</el-button>
    <el-button type="primary" style="float:right" @click="Xml2Json"
      >Xml2Json</el-button
    >-->

    <!--  <div id="decryptDate" v-html="result"></div>-->
  </div>
</template>

<script>
import { getJavaDecrypt } from "../../../../api/api";
import x2js from "x2js";
Vue.prototype.$x2js = new x2js();
export default {
  result: "",
  textareaoutput: "",
  textareaintput: "",

  methods: {
    // json转xml
    Json2Xml: function() {
      this.textareaoutput = this.$x2js.js2xml(JSON.parse(this.textareainput));
      this.$forceUpdate();
    },

    Xml2Json: function() {
      this.textareainput = this.$x2js.xml2js(this.textareaoutput);
      this.textareainput = JSON.stringify(this.textareainput);
      this.$forceUpdate();
    },
  },
  mounted() {
    this.$nextTick(function() {
      //this.RSADecrypt();
    });
  },
};
</script>
<style scoped>
h1 {
  color: red;
}

.color-red {
  color: red;
  border: 1px solid #e8e8e8;
  padding: 0px 6px 0 9px;
  margin-right: 23px;
}
</style>
